package com.ruoyi.xgssc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xgssc.domain.XgStudyStyleConstruction;
import com.ruoyi.xgssc.service.IXgStudyStyleConstructionService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.courses.domain.JwCourses;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学风建设Controller
 * 
 * @author ruoyi
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/xgssc/xgssc")
public class XgStudyStyleConstructionController extends BaseController
{
    @Autowired
    private IXgStudyStyleConstructionService xgStudyStyleConstructionService;

    /**
     * 查询学风建设列表
     */
    @PreAuthorize("@ss.hasPermi('xgssc:xgssc:list')")
    @GetMapping("/list")
    public TableDataInfo list(XgStudyStyleConstruction xgStudyStyleConstruction)
    {
        startPage();
        List<XgStudyStyleConstruction> list = xgStudyStyleConstructionService.selectXgStudyStyleConstructionList(xgStudyStyleConstruction);
        return getDataTable(list);
    }

    /**
     * 导出学风建设列表
     */
    @PreAuthorize("@ss.hasPermi('xgssc:xgssc:export')")
    @Log(title = "学风建设", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XgStudyStyleConstruction xgStudyStyleConstruction)
    {
        List<XgStudyStyleConstruction> list = xgStudyStyleConstructionService.selectXgStudyStyleConstructionList(xgStudyStyleConstruction);
        ExcelUtil<XgStudyStyleConstruction> util = new ExcelUtil<XgStudyStyleConstruction>(XgStudyStyleConstruction.class);
        util.exportExcel(response, list, "学风建设数据");
    }

    /**
     * 获取学风建设详细信息
     */
    @PreAuthorize("@ss.hasPermi('xgssc:xgssc:query')")
    @GetMapping(value = "/{sscId}")
    public AjaxResult getInfo(@PathVariable("sscId") Long sscId)
    {
        return success(xgStudyStyleConstructionService.selectXgStudyStyleConstructionBySscId(sscId));
    }

    /**
     * 新增学风建设
     */
    @PreAuthorize("@ss.hasPermi('xgssc:xgssc:add')")
    @Log(title = "学风建设", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XgStudyStyleConstruction xgStudyStyleConstruction)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        xgStudyStyleConstruction.setDeptId(104L);
        xgStudyStyleConstruction.setUserId(user.getUserId());
        return toAjax(xgStudyStyleConstructionService.insertXgStudyStyleConstruction(xgStudyStyleConstruction));
    }
    /**
     * 修改学风建设
     */
    @PreAuthorize("@ss.hasPermi('xgssc:xgssc:edit')")
    @Log(title = "学风建设", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XgStudyStyleConstruction xgStudyStyleConstruction)
    {
        return toAjax(xgStudyStyleConstructionService.updateXgStudyStyleConstruction(xgStudyStyleConstruction));
    }

    /**
     * 删除学风建设
     */
    @PreAuthorize("@ss.hasPermi('xgssc:xgssc:remove')")
    @Log(title = "学风建设", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sscIds}")
    public AjaxResult remove(@PathVariable Long[] sscIds)
    {
        return toAjax(xgStudyStyleConstructionService.deleteXgStudyStyleConstructionBySscIds(sscIds));
    }
}
